import Contract from "../main/sc/Contract"
import Log from "../main/util/Log"

export default class CAssets extends Contract{
    constructor() {
        super();
    }
    transfer(from, to, amount){
        Log.i(CAssets, `transfer from:${from} to:${to} amount:${amount}`);
    }

    set(m){
        Log.i(CAssets, `CAssets set:${m} `);
    }
    /**
     * @param {Context} ctx
     * @type {void}
     */
    init(ctx){
        this._ctx = ctx;
    }
    /**
     * 
     * @param {Context} ctx
     * @param {string} action
     * @param {string} data
     * @type {void}
     */
    onAction(ctx, action, data){
        let d = JSON.parse(data);
        switch(action){
            case "transfer":
                this.transfer(d.from, d.to, d.amount);
                break;
            case "set":
                this.set(d);
                break;
        }
        Log.i(CAssets, `CAssets onAction action:${action} data:${data} `);
    }

}

